home *** CD-ROM | disk | FTP | other *** search
- '===========================================================================
- '
- ' %MODULE TallyHo!.b
- ' %CREATION DATE 01-Feb-1994
- ' %PROGRAMMER Dennis Schank
- ' %VERSION V1.1
- '
- '
- ' %ABSTRACT A game in which the number of moves you make upon a grid
- ' is determined by the value of the square selected with the
- ' mouse. The path you have already taken cannot be crossed
- ' and the attempt to do so will end the game.
- '
- '
- ' %MODIFICATION HISTORY
- ' V1.1 05-Feb-1994 Fixed bug that caused cursor to overlap
- ' onto used blocks on WB screens of 4 or 8
- ' colors. [ds]
- '
- ' V1.0 01-Feb-1994 First written [ds]
- '
- '===========================================================================
-
- 'Set traps
- ON MENU GOSUB Menu_Option_Selected
- MENU ON
- ON MOUSE GOSUB Mouse_Button_Pushed
- MOUSE ON
- ON WINDOW GOSUB ShutDown
- WINDOW ON
-
- 'Includes
- #INCLUDE <longval.h> 'Allow the conversion of strings containing long values (replaces VAL function)
- #INCLUDE <font.h> 'Allows the changing of fonts
- FONTSET("XEN",9) 'Set to a font that will allow more characters per inch
-
- 'String declarations
- STRING WindowTitle$ SIZE 80 'Holds string to display on window title bar
- STRING TopTen_File$ SIZE 20 'Holds name of file to store high scores
- STRING Player$ SIZE 80 'Holds name of player if a top ten score is achieved
- STRING TopTenTitle$ SIZE 40 'Holds the string to be displayed at top of top ten list
-
- 'Define Constants
- CONST _ROWS = 13, _COLS = 56 'Blocks displayed on screen
-
- 'Set all integer variables to type short
- DEFINT a-z
-
- 'Override DEFINT for integer variables that need to be other than short
- SINGLE CurrentScore 'Holds the current score displayed on screen
- SINGLE Tally 'Holds the button value as it is used
- SINGLE Bonus 'Holds the bonus value for each mode
-
- 'Define arrays
- DIM TopTenName$(10) SIZE 31 'Names of top ten scorers
- DIM TopTenScore$(10) SIZE 12 'Scores of top ten scorers
- DIM TopTenValChk$(10) SIZE 20 'Holds validity check number of high scores
- DIM Grid(_COLS,_ROWS) 'Holds the values of the blocks on the grid
-
- 'Open main window
- LET WindowTitle$ = "TallyHo! Version 1.1 copyright " + CHR$(169) + " 1994 by Dennis Schank"
- WINDOW 1,WindowTitle$,(0,14)-(635,214),30
- WINDOW OUTPUT 1
- FONTSET("XEN",9) 'Set to a font that will allow more characters per inch
-
-
- 'Make menus - Place 10 spaces at end of longest menu item for each menu that has quick keys
- 'Menu 1
- MENU 1,0,1,"Options "
- MENU 1,1,1," View Scores ","V"
- MENU 1,2,1," Help","H"
- MENU 1,3,1," About","A"
- MENU 1,4,1," Quit","Q"
- 'Menu 2
- MENU 2,0,1,"Play "
- MENU 2,1,1," New Game","G"
- MENU 2,2,1," End Current Game ","E"
- 'Menu 3
- MENU 3,0,1,"Mode "
- MENU 3,1,1," Beginner"
- MENU 3,2,2," Casual Player"
- MENU 3,3,1," Crazed Fanatic "
-
-
- ' ==== Set coordinates ====
-
- 'Button coordinates
- LET ButtonX = 6 'x coordinate to start first button (top left corner)
- LET ButtonY = 9 'y coordinate to start first button (top left corner)
- LET BtnHeight = 10 'Height of buttons in pixels
- LET BtnWidth = 10 'Width of buttons in pixels
-
- 'Score Box coordinates
- LET ScoreBoxX = 220 'x coordinate for the score box (top left corner)
- LET ScoreBoxY = 160 'y coordinate for the score box (top left corner)
- LET SBoxWidth = 200 'Width of scorebox in pixels
- LET SBoxHeight = 16 'Height of scorebox in pixels
-
-
- ' ==== Begin main routine ====
-
-
- 'Set default values
- LET Mode_Block_Value = 6 'Maximum value for blocks in Casual Player mode
- LET Mode_Bonus_Value = 7000 'Bonus given for each block used in Casual Player mode
- LET TopTen_File$ = "TH!_TopTen_CP" 'File to save top ten scores in Casual Player mode
- LET Mode = 2 'Mode flag (1=Beginner, 2=Casual Player, 3=Crazed Fanatic)
-
- GOSUB Load_TopTen
-
- RANDOMIZE TIMER 'Makes sure that there is a different set of random numbers each time run
- GOSUB New_Game
-
-
- ' +==================================+
- ' | Wait for mouse or menu activity |
- ' +==================================+
-
- WHILE -1
- SLEEP
- WEND
-
-
-
- ' +===============+
- ' | SUBROUTINES |
- ' +===============+
-
- ' ---- Initialize Variables ----
-
- Initialize_Variables:
- LET GameOver = 0 'Set to FALSE
- LET ScoreNotChecked = -1 'Set to TRUE
- LET Tally = 0 'Initialize running score variable
- LET OriginalX = INT(RND*_COLS)+1 'Randomly select cursor start x on grid
- LET OriginalY = INT(RND*_ROWS)+1 'Randomly select cursor start y on grid
- LET CurrentX = OriginalX 'Set current position x to cursor position x
- LET CurrentY = OriginalY 'Set current position y to cursor position y
- LET CurrentScore = Grid(CurrentX,CurrentY) 'Start score at value of starting block
- RETURN
-
-
- ' ---- Load top ten scores ----
-
- Load_TopTen:
- OPEN "I",#1,TopTen_File$
- FOR s = 1 TO 10
- IF EOF(1) THEN 'Initialize all scores if file does not exist
- LET TopTenScore$(s) = "10000"
- LET TopTenName$(s) = "TallyHo!"
- LET TopTenValChk$(s) = STR$(SIN(ASC(TopTenName$(s)) + LONGVAL&(MID$(TopTenScore$(s),2,3))))
- ELSE
- INPUT #1,TopTenScore$(s),TopTenName$(s),TopTenValChk$(s)
- 'Check to see if file has been tampered with
- IF STR$(SIN(ASC(TopTenName$(s)) + LONGVAL&(MID$(TopTenScore$(s),2,3)))) <> TopTenValChk$(s) THEN
- LET i = MSGBOX("TOP TEN file is corrupt...A new file will be created.","Confirm")
- FOR i = 1 TO 10
- LET TopTenScore$(i) = "10000"
- LET TopTenName$(i) = "TallyHo!"
- LET TopTenValChk$(i) = STR$(SIN(ASC(TopTenName$(i)) + LONGVAL&(MID$(TopTenScore$(i),2,3))))
- NEXT i
- LET s = 10
- END IF
- END IF
- NEXT s
- CLOSE #1
- RETURN
-
-
- ' ---- Display new game stuff ----
-
- New_Game:
- MENU 2,2,1 'Enable "End Current Game" menu option
- CLS 'Clear screen
- 'Display the score box
- LINE (ScoreBoxX,ScoreBoxY)-(ScoreBoxX+SBoxWidth,ScoreBoxY),2
- LINE (ScoreBoxX,ScoreBoxY)-(ScoreBoxX,ScoreBoxY+SBoxHeight),2
- LINE (ScoreBoxX+SBoxWidth,ScoreBoxY+SBoxHeight)-(ScoreBoxX+SBoxWidth,ScoreBoxY),1
- LINE (ScoreBoxX+SBoxWidth,ScoreBoxY+SBoxHeight)-(ScoreBoxX,ScoreBoxY+SBoxHeight),1
- LINE (ScoreBoxX+(INT(SBoxWidth/2)),ScoreBoxY+2)-(ScoreBoxX+(SBoxWidth-6),ScoreBoxY+2),1
- LINE (ScoreBoxX+(INT(SBoxWidth/2)),ScoreBoxY+2)-(ScoreBoxX+(INT(SBoxWidth/2)),ScoreBoxY+(SBoxHeight-2)),1
- LINE (ScoreBoxX+(SBoxWidth-2),ScoreBoxY+(SBoxHeight-2))-(ScoreBoxX+(SBoxWidth-2),ScoreBoxY+2),2
- LINE (ScoreBoxX+(SBoxWidth-2),ScoreBoxY+(SBoxHeight-2))-(ScoreBoxX+(INT(SBoxWidth/2)),ScoreBoxY+(SBoxHeight-2)),2
- PENUP
- SETXY ScoreBoxX+INT(SBoxWidth/5),ScoreBoxY+(2*INT(SBoxHeight/3))
- PRINT "SCORE";
- 'Create the grid buttons with values in them
- LET RowNum = 0
- FOR y = ButtonY TO ((BtnHeight+1)*(_ROWS-1))+ButtonY STEP BtnHeight+1
- ++RowNum
- LET ColNum = 0
- FOR x = ButtonX TO ((BtnWidth+1)*(_COLS-1))+ButtonX STEP BtnWidth+1
- ++ColNum
- LINE (x,y)-(x+BtnWidth,y),2 'TOP
- LINE (x,y)-(x,y+BtnHeight),2 'LEFT
- LINE (x+BtnWidth,y+BtnHeight)-(x+BtnWidth,y),1 'RIGHT
- LINE (x+BtnWidth,y+BtnHeight)-(x,y+BtnHeight),1 'BOTTOM
- LET BtnValue = INT(RND*Mode_Block_Value)+1 'Randomly set button value
- LET Grid(ColNum,RowNum) = BtnValue 'Assign value to corresponding grid array position
- PENUP
- SETXY x+3,y+(BtnHeight-3)
- PRINT RIGHT$(STR$(BtnValue),1); 'Print value in button after removing leading space
- NEXT x
- NEXT y
- GOSUB Initialize_Variables
- 'Determine the top left pixel of the starting position of the cursor
- LET CurrentBtnX = ((BtnWidth+1)*(CurrentX-1))+ButtonX
- LET CurrentBtnY = ((BtnHeight+1)*(CurrentY-1))+ButtonY
- 'Give cursor block illusion of being pressed in
- LINE (CurrentBtnX,CurrentBtnY)-(CurrentBtnX+BtnWidth,CurrentBtnY),1
- LINE (CurrentBtnX,CurrentBtnY)-(CurrentBtnX,CurrentBtnY+BtnHeight),1
- LINE (CurrentBtnX+BtnWidth,CurrentBtnY+BtnHeight)-(CurrentBtnX+BtnWidth,CurrentBtnY),2
- LINE (CurrentBtnX+BtnWidth,CurrentBtnY+BtnHeight)-(CurrentBtnX,CurrentBtnY+BtnHeight),2
- 'Color the cursor block
- LINE (CurrentBtnX+1,CurrentBtnY+1)-(CurrentBtnX+BtnWidth-1,CurrentBtnY+BtnHeight-1),11,BF
- PENUP
- SETXY 4+(ScoreBoxX+INT(SBoxWidth/2)),ScoreBoxY+(2*INT(SBoxHeight/3))
- PRINT CurrentScore;" " 'Print the starting score in scorebox
- RETURN
-
-
- ' ---- Tally the score if valid move ----
-
- Tally_It:
- MENU 2,1,0 'Disable "New Game" menu option to avoid accidental loss of accumulated score
- MENU 3,0,0 'Disable "Mode" menu so user must end the game in order to change mode
- LET Tally = Grid(CurrentX,CurrentY) 'Get value of block clicked on
- 'Determine which direction movement is being made
- IF CurrentX < OriginalX THEN
- LET DestinyX = OriginalX - Tally
- ELSE
- IF CurrentX > OriginalX THEN
- LET DestinyX = OriginalX + Tally
- ELSE
- LET DestinyX = OriginalX
- END IF
- END IF
- IF CurrentY < OriginalY THEN
- LET DestinyY = OriginalY - Tally
- ELSE
- IF CurrentY > OriginalY THEN
- LET DestinyY = OriginalY + Tally
- ELSE
- LET DestinyY = OriginalY
- END IF
- END IF
- LET Tally = 0
- LET Bonus = 0
- 'Tally up the values of the blocks used
- FOR b = 1 TO Mode_Block_Value 'Repeats for maximum possible moves
- 'Determine the top left pixel of the starting position of the cursor
- LET CurrentBtnX = ((BtnWidth+1)*(CurrentX-1))+ButtonX
- LET CurrentBtnY = ((BtnHeight+1)*(CurrentY-1))+ButtonY
- 'Check to see if path is crossed
- IF Grid(CurrentX,CurrentY) = 0 THEN
- 'Stop cursor in current block and color it because path was crossed
- LINE (CurrentBtnX+1,CurrentBtnY+1)-(CurrentBtnX+BtnWidth-1,CurrentBtnY+BtnHeight-1),8,BF
- 'Clear original cursor location
- LET OriginalBtnX = ((BtnWidth+1)*(OriginalX-1))+ButtonX
- LET OriginalBtnY = ((BtnHeight+1)*(OriginalY-1))+ButtonY
- LINE (OriginalBtnX+1,OriginalBtnY+1)-(OriginalBtnX+BtnWidth-1,OriginalBtnY+BtnHeight-1),0,BF
- BEEP
- 'Inform player that game is over
- LET GameOver = MSGBOX("You have crossed your previous path. - GAME OVER","OK")
- GOSUB Check_Score 'See if score is in top ten
- GOSUB Show_TopTen 'Display the top ten list
- MENU 2,1,1 'Enable "New Game" menu option
- MENU 2,2,0 'Disable "End Current Game" menu option
- MENU 3,0,1 'Enable "Mode" menu
- LET b = Mode_Block_Value 'Set value of b to last iteration of loop
- GOTO PathFinished 'Go to the end of the loop so exit will be performed
- END IF
- 'Since path was not crossed, give current position illustion of being pressed
- LINE (CurrentBtnX,CurrentBtnY)-(CurrentBtnX+BtnWidth,CurrentBtnY),1
- LINE (CurrentBtnX,CurrentBtnY)-(CurrentBtnX,CurrentBtnY+BtnHeight),1
- LINE (CurrentBtnX+BtnWidth,CurrentBtnY+BtnHeight)-(CurrentBtnX+BtnWidth,CurrentBtnY),2
- LINE (CurrentBtnX+BtnWidth,CurrentBtnY+BtnHeight)-(CurrentBtnX,CurrentBtnY+BtnHeight),2
- 'Give tentative points for block used
- LET Bonus = Bonus + Mode_Bonus_Value
- LET Tally = Tally + Grid(CurrentX,CurrentY)
- 'Set value of block to zero so it can be checked later for overlap
- LET Grid(CurrentX,CurrentY) = 0
- 'Check to see if the range of moves have been made
- IF CurrentX = DestinyX AND CurrentY = DestinyY THEN
- 'Stop cursor in current block and color it because range of moves complete
- LINE (CurrentBtnX+1,CurrentBtnY+1)-(CurrentBtnX+BtnWidth-1,CurrentBtnY+BtnHeight-1),11,BF
- 'Clear original cursor location
- LET OriginalBtnX = ((BtnWidth+1)*(OriginalX-1))+ButtonX
- LET OriginalBtnY = ((BtnHeight+1)*(OriginalY-1))+ButtonY
- LINE (OriginalBtnX+1,OriginalBtnY+1)-(OriginalBtnX+BtnWidth-1,OriginalBtnY+BtnHeight-1),0,BF
- 'Make current location the original to prepare for player's next move
- LET OriginalX = CurrentX
- LET OriginalY = CurrentY
- 'Give 100 times the value of all used blocks and add bonus
- LET Tally = (Tally * 100) + Bonus
- 'Add tentative score to current score and display
- LET CurrentScore = CurrentScore + Tally
- PENUP
- SETXY 4+(ScoreBoxX+INT(SBoxWidth/2)),ScoreBoxY+(2*INT(SBoxHeight/3))
- PRINT CurrentScore;" "
- LET b = Mode_Block_Value 'Set value of b to last iteration of loop
- GOTO PathFinished 'Go to the end of the loop so exit will be performed
- ELSE
- 'Since range of moves not complete, just clear the button text
- LINE (CurrentBtnX+1,CurrentBtnY+1)-(CurrentBtnX+BtnWidth-1,CurrentBtnY+BtnHeight-1),0,BF
- END IF
- 'Increment or decrement values of cursor on grid in accordance to direction of original move
- IF DestinyX < OriginalX THEN --CurrentX
- IF DestinyX > OriginalX THEN ++CurrentX
- IF DestinyY < OriginalY THEN --CurrentY
- IF DestinyY > OriginalY THEN ++CurrentY
- 'Check to see if cursor is beyond the edge of the grid
- IF CurrentX < 1 OR CurrentX > _COLS OR CurrentY < 1 OR CurrentY > _ROWS THEN
- 'Since edge of grid was reached move cursor back to last position on grid
- IF DestinyX < OriginalX THEN ++CurrentX
- IF DestinyX > OriginalX THEN --CurrentX
- IF DestinyY < OriginalY THEN ++CurrentY
- IF DestinyY > OriginalY THEN --CurrentY
- 'Stop cursor in current block and color it because range of moves complete
- LINE (CurrentBtnX+1,CurrentBtnY+1)-(CurrentBtnX+BtnWidth-1,CurrentBtnY+BtnHeight-1),11,BF
- 'Clear original cursor location
- LET OriginalBtnX = ((BtnWidth+1)*(OriginalX-1))+ButtonX
- LET OriginalBtnY = ((BtnHeight+1)*(OriginalY-1))+ButtonY
- LINE (OriginalBtnX+1,OriginalBtnY+1)-(OriginalBtnX+BtnWidth-1,OriginalBtnY+BtnHeight-1),0,BF
- 'Make current location the original to prepare for player's next move
- LET OriginalX = CurrentX
- LET OriginalY = CurrentY
- 'Give 100 times the value of all used blocks and add bonus
- LET Tally = (Tally * 100) + Bonus
- 'Add tentative score to current score and display
- LET CurrentScore = CurrentScore + Tally
- PENUP
- SETXY 4+(ScoreBoxX+INT(SBoxWidth/2)),ScoreBoxY+(2*INT(SBoxHeight/3))
- PRINT CurrentScore;" "
- LET b = Mode_Block_Value 'Set value of b to last iteration of loop
- END IF
- PathFinished:
- NEXT b
- RETURN
-
-
- ' ---- Check to see if score is in top ten ----
- Check_Score:
- 'See if score is greater than lowest top ten score
- IF CurrentScore > LONGVAL&(TopTenScore$(10)) THEN
- 'Player made top ten so prompt for name
- LET Player$ = LEFT$(INPUTBOX$("Please enter your name:","You made the TOP TEN scores list.",Player$),65)
- 'Determine which position player belongs in
- FOR s = 1 TO 10
- IF CurrentScore > LONGVAL&(TopTenScore$(s)) THEN
- { Since the players score is larger than the person currently in this position,
- go to the end of the array and move everyone down one.
- }
- FOR c = 10 TO s+1 STEP -1
- LET TopTenScore$(c) = TopTenScore$(c-1)
- LET TopTenName$(c) = TopTenName$(c-1)
- LET TopTenValChk$(c) = TopTenValChk$(c-1)
- NEXT c
- 'Now put player in place of last person moved down
- LET TopTenScore$(s) = STR$(CurrentScore)
- LET TopTenName$(s) = Player$
- { Take the ascii value of the first character of the player's name, add it to
- the first three digits of the score, and return the SINE of the total as the
- validity check for the purpose of checking for tampering of high scores.
- }
- LET TopTenValChk$(s) = STR$(SIN(ASC(TopTenName$(s)) + LONGVAL&(MID$(STR$(CurrentScore),2,3))))
- LET s = 10
- END IF
- NEXT s
- GOSUB Write_High_Scores 'Write the current list of high scores to output file
- END IF
- LET ScoreNotChecked = 0 'Set to FALSE
- RETURN
-
-
- ' ---- Display the top ten list ----
-
- Show_TopTen:
- 'Open new window to display scores
- WINDOW 2,"TallyHo! TOP TEN scores...",(30,25)-(605,188),24
- WINDOW OUTPUT 2
- FONTSET("XEN",9) 'Set to a font that will allow more characters per inch
- PRINT ""
- 'Determine what tile to display at top of listing and print it
- IF Mode = 1 THEN LET TopTenTitle$ = " Top Ten Scores for Beginner Mode"
- IF Mode = 2 THEN LET TopTenTitle$ = "Top Ten Scores for Casual Player Mode"
- IF Mode = 3 THEN LET TopTenTitle$ = "Top Ten Scores for Crazed Fanatic Mode"
- PRINT STRING$(27," ");TopTenTitle$
- PRINT ""
- 'Display all scores
- FOR s = 1 TO 10
- IF s < 10 THEN PRINT " ";
- PRINT " ";STR$(s);" ";LEFT$(TopTenName$(s) + STRING$(67,"."),67);STRING$(10 - LEN(TopTenScore$(s)),".");TopTenScore$(s)
- NEXT s
- PRINT ""
- PRINT ""
- INPUT " Press [ENTER] to exit... ",s
- WINDOW CLOSE 2
- WINDOW OUTPUT 1
- RETURN
-
-
- ' ---- Display HELP ----
-
- Display_Help:
- 'Open new window to display help
- WINDOW 3,"TallyHo! - HELP",(0,14)-(635,214),24
- WINDOW OUTPUT 3
- FONTSET("XEN",9) 'Set to a font that will allow more characters per inch
- 'Display help information
- PRINT ""
- PRINT ""
- PRINT " TallyHo! is a simple game in which the object is to move upon a grid of numbers to tally up"
- PRINT " the highest score possible. This is accomplished by clicking the mouse pointer on a number"
- PRINT " block that is adjacent to the block occupied by the colored cursor. The number you click on"
- PRINT " determines how far the cursor will move. The exception is if there is not enough blocks to"
- PRINT " finish the range of moves before the cursor reaches the edge of the grid. In this case, the"
- PRINT " cursor stops when it reaches the edge. The game ends when the cursor enters a block that has"
- PRINT " already been used. If you have no more valid moves, select End Current Game from the Play"
- PRINT " menu or force the cursor into a used block so your score can be checked against high scores."
- PRINT ""
- PRINT " The block values are selected randomly as is the start position of the cursor. You may move"
- PRINT " in any direction from the cursor (left, right, up, down, diagonal). The score is calculated by"
- PRINT " giving you 100 times the value of each block used plus additional bonus points for each block"
- PRINT " used. The values of the blocks will range from 1 to 4 in Beginner mode, 1 to 6 in Casual Player"
- PRINT " mode, and 1 to 9 in Crazed Fanatic mode. The bonus points given for each block used is 5,000 in"
- PRINT " Beginner mode, 7,000 in Casual Player mode, and 10,000 in Crazed Fanatic mode. Casual Player"
- PRINT " mode is the default. HAVE FUN!"
- PRINT ""
- PRINT ""
- INPUT " Press [ENTER] to exit... ",s
- WINDOW CLOSE 3
- WINDOW OUTPUT 1
- RETURN
-
-
- ' ---- Change the mode ----
-
- Change_Mode:
- LET ModeChanged = 0 'Set to FALSE
- IF MenuItem = 1 AND Mode <> 1 THEN
- MENU 3,1,2 'Put a checkmark beside "Beginner" menu option
- MENU 3,2,1 'Take checkmark off of "Casual Player" menu option if exists
- MENU 3,3,1 'Take checkmark off of "Crazed Fanatic" menu option if exists
- LET Mode_Block_Value = 4 'Maximum value for blocks in Beginner mode
- LET Mode_Bonus_Value = 5000 'Bonus given for each block used in Beginner mode
- LET TopTen_File$ = "TH!_TopTen_B" 'File to save top ten scores in Beginner mode
- LET Mode = 1 'Mode flag (1=Beginner, 2=Casual Player, 3=Crazed Fanatic)
- LET ModeChanged = 1 'Set to TRUE
- END IF
- IF MenuItem = 2 AND Mode <> 2 THEN
- MENU 3,1,1 'Take checkmark off of "Beginner" menu option if exists
- MENU 3,2,2 'Put a checkmark beside "Casual Player" menu option
- MENU 3,3,1 'Take checkmark off of "Crazed Fanatic" menu option if exists
- LET Mode_Block_Value = 6 'Maximum value for blocks in Casual Player mode
- LET Mode_Bonus_Value = 7000 'Bonus given for each block used in Casual Player mode
- LET TopTen_File$ = "TH!_TopTen_CP" 'File to save top ten scores in Casual Player mode
- LET Mode = 2 'Mode flag (1=Beginner, 2=Casual Player, 3=Crazed Fanatic)
- LET ModeChanged = 1 'Set to TRUE
- END IF
- IF MenuItem = 3 AND Mode <> 3 THEN
- MENU 3,1,1 'Take checkmark off of "Beginner" menu option if exists
- MENU 3,2,1 'Take checkmark off of "Casual Player" menu option if exists
- MENU 3,3,2 'Put a checkmark beside "Crazed Fanatic" menu option
- LET Mode_Block_Value = 9 'Maximum value for blocks in Crazed Fanatic mode
- LET Mode_Bonus_Value = 10000 'Bonus given for each block used in Crazed Fanatic mode
- LET TopTen_File$ = "TH!_TopTen_CF" 'File to save top ten scores in Crazed Fanatic mode
- LET Mode = 3 'Mode flag (1=Beginner, 2=Casual Player, 3=Crazed Fanatic)
- LET ModeChanged = 1 'Set to TRUE
- END IF
- 'Check to see if mode was changed, if so, load scores for that mode and start a new game
- IF ModeChanged THEN
- GOSUB Load_TopTen
- GOSUB New_Game
- END IF
- RETURN
-
-
- ' ---- Show information about TallyHo! ----
-
- Show_About:
- 'Open new window to display information about TallyHo!
- WINDOW 4,"About TallyHo!...",(30,30)-(315,190),24
- WINDOW OUTPUT 4
- FONTSET("XEN",9) 'Set to a font that will allow more characters per inch
- PRINT ""
- PRINT ""
- PRINT " TallyHo! Version 1.1"
- PRINT " copyright ";CHR$(169);" February 1994 by"
- PRINT ""
- PRINT " Dennis Schank"
- PRINT " 1523 N 47th Street"
- PRINT " Kansas City, KS 66102"
- PRINT " USA"
- PRINT ""
- PRINT " Written entirely in ACE-Basic V2.0
- PRINT " copyright ";CHR$(169);" 1991-1994 by David Benn"
- PRINT ""
- PRINT ""
- INPUT " Press [ENTER] to exit... ",s
- WINDOW CLOSE 4
- WINDOW OUTPUT 1
- RETURN
-
-
- ' ---- Write the high scores file ----
-
- Write_High_Scores:
- 'Open the file for the high scores for given mode and write contest of arrays
- OPEN "O",#1,TopTen_File$
- FOR s = 1 TO 10
- WRITE #1,TopTenScore$(s),TopTenName$(s),TopTenValChk$(s)
- NEXT s
- CLOSE #1
- RETURN
-
-
- ' ---- Left mouse button was pushed ----
-
- Mouse_Button_Pushed:
- 'Determine which button, if any, was clicked
- IF GameOver THEN RETURN 'Do not allow clicking on buttons if game is not active
- LET SelectedX = 0
- LET SelectedY = 0
- 'Check only valid columns (cursor column, 1 left of cursor, 1 right cursor)
- FOR x = CurrentX-1 TO CurrentX+1
- LET CheckX = ((BtnWidth+1)*(x-1))+ButtonX
- IF MOUSE(1) > CheckX AND MOUSE(1) < CheckX+BtnWidth THEN
- LET SelectedX = x
- END IF
- NEXT x
- 'Check only valid rows (cursor row, 1 above cursor, 1 below cursor)
- FOR y = CurrentY-1 TO CurrentY+1
- LET CheckY = ((BtnHeight+1)*(y-1))+ButtonY
- IF MOUSE(2) > CheckY AND MOUSE(2) < CheckY+BtnHeight THEN
- LET SelectedY = y
- END IF
- NEXT y
- 'Accept only if clicked on block other than block containing cursor
- IF NOT (SelectedX = CurrentX AND SelectedY = CurrentY) THEN
- 'Make sure area clicked is within grid boundaries
- IF SelectedX > 0 AND SelectedX <= _COLS AND SelectedY > 0 AND SelectedY <= _ROWS THEN
- 'Move current position to that of block clicked
- LET CurrentX = SelectedX
- LET CurrentY = SelectedY
- GOSUB Tally_It 'Make the necessary moves
- END IF
- END IF
- Mouse_Return:
- { Do not return until player has released mouse button to avoid unwanted
- selection of blocks due to dragging of mouse.
- }
- WHILE MOUSE(0) = -1
- WEND
- RETURN
-
-
- ' ---- Menu option was selected ----
-
- Menu_Option_Selected:
- LET MenuNum = MENU(0) 'Determine which menu selected from
- LET MenuItem = MENU(1) 'Determine which item of the menu selected
- 'See if "View Scores" menu item was selected
- IF MenuNum = 1 AND MenuItem = 1 THEN
- GOSUB Show_TopTen
- END IF
- 'See if "Help" menu item was selected
- IF MenuNum = 1 AND MenuItem = 2 THEN
- GOSUB Display_Help
- END IF
- 'See if "About" menu item was selected
- IF MenuNum = 1 AND MenuItem = 3 THEN
- GOSUB Show_About
- END IF
- 'See if "Quit" menu item was selected
- IF MenuNum = 1 AND MenuItem = 4 THEN
- GOSUB ShutDown
- END IF
- 'See if "New Game" menu item was selected
- IF MenuNum = 2 AND MenuItem = 1 THEN
- GOSUB New_Game
- END IF
- 'See if "End Current Game" menu item was selected
- IF MenuNum = 2 AND MenuItem = 2 THEN
- 'Double check player's intentions to avoid losing accumulated score
- LET GameOver = MSGBOX("Are you sure you want to end this game?","What did I just say?","Are you nuts?")
- 'See if player did indeed intend to end game
- IF GameOver THEN
- GOSUB Check_Score 'See if player made top ten scores list
- GOSUB Show_TopTen 'Display the top ten scores list
- MENU 2,1,1 'Enable "New Game" menu option
- MENU 2,2,0 'Disable "End Current Game" menu option
- MENU 3,0,1 'Enable "Mode" menu
- END IF
- END IF
- 'See if an item was selected from the "Mode" menu
- IF MenuNum = 3 THEN
- GOSUB Change_Mode
- END IF
- Menu_Return:
- RETURN
-
-
- ShutDown:
- IF ScoreNotChecked THEN
- GOSUB Check_Score
- END IF
- WINDOW CLOSE 1
- STOP 'End the program
- 'This RETURN will never be reached - It's only purpose is to avoid compiler errors
- ' RETURN
-